<?php


namespace frontend\controllers\cyf;


use frontend\controllers\common;
use servers\cyf\QiniuServer;
use yii\web\Controller;
use yii\web\Request;
use yii\web\UploadedFile;

class FileController extends Controller
{
    /**
     * 上传文件
     * @param Request $request
     * @throws \Exception
     */
    public function actionUpload(Request $request)
    {
        //获取文件本地路径
        $filePath =UploadedFile::getInstanceByName('pic_url')->tempName;
        $res = QiniuServer::uploadFile($filePath);
        if(!$res) return common::fail('50001','null','文件上传失败');
        return common::fail('50001',$res,'文件上传成功');
    }
}